package com.pocket.insight.base.sql.bo;

import com.pocket.insight.base.mql.TypedVal;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.configurationprocessor.json.JSONObject;

/**
 * 描述：SQL执行结果
 *
 * @author shuize
 * @create 2024/11/29
 */
@Data
@NoArgsConstructor
public class SqlExecInfo {

    private String     jdbcUrl;         // 数据连接 url
    private String     vendorKey;       // url 连接池 key
    private String     sql;             // 要执行的 sql
    private TypedVal   query;
    private JSONObject importInfo;
    private String     requestId;

    public SqlExecInfo(String jdbcUrl, Object query, String vendorKey) {
        this.jdbcUrl = jdbcUrl;
        this.vendorKey = vendorKey;
        if (query instanceof TypedVal typedQuery) {
            if (typedQuery.getStr() != null) {
                this.sql = typedQuery.getStr();
            } else {
                this.query = (TypedVal) query;
            }
        } else {
            this.sql = (String) query;
        }
    }



}
